/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author HoangHai
 */
@Entity
@Table(name = "Classes")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Classes.findBySemID", query = "SELECT DISTINCT c FROM Semester s JOIN s.resultList r JOIN r.classID c WHERE s.seID = :seID"),
    @NamedQuery(name = "Classes.findAll", query = "SELECT c FROM Classes c"),
    @NamedQuery(name = "Classes.findByClassID", query = "SELECT c FROM Classes c WHERE c.classID = :classID"),
    @NamedQuery(name = "Classes.findByClassName", query = "SELECT c FROM Classes c WHERE c.className = :className"),
    @NamedQuery(name = "Classes.findByCreateDate", query = "SELECT c FROM Classes c WHERE c.createDate = :createDate"),
    @NamedQuery(name = "Classes.findByStartDate", query = "SELECT c FROM Classes c WHERE c.startDate = :startDate"),
    @NamedQuery(name = "Classes.findByEndDate", query = "SELECT c FROM Classes c WHERE c.endDate = :endDate")})
public class Classes implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    @Basic(optional = false)
    //@NotNull
    @Column(name = "ClassID")
    private Integer classID;
    @Size(max = 50)
    @Column(name = "ClassName")
    private String className;
    @Column(name = "CreateDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createDate;
    @Column(name = "StartDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date startDate;
    @Column(name = "EndDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date endDate;
    @OneToMany(mappedBy = "classID")
    private List<Result> resultList;
    @OneToMany(mappedBy = "classID")
    private List<StuDetail> stuDetailList;

    public Classes() {
    }

    public Classes(Integer classID) {
        this.classID = classID;
    }

    public Integer getClassID() {
        return classID;
    }

    public void setClassID(Integer classID) {
        this.classID = classID;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    @XmlTransient
    public List<Result> getResultList() {
        return resultList;
    }

    public void setResultList(List<Result> resultList) {
        this.resultList = resultList;
    }

    @XmlTransient
    public List<StuDetail> getStuDetailList() {
        return stuDetailList;
    }

    public void setStuDetailList(List<StuDetail> stuDetailList) {
        this.stuDetailList = stuDetailList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (classID != null ? classID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Classes)) {
            return false;
        }
        Classes other = (Classes) object;
        if ((this.classID == null && other.classID != null) || (this.classID != null && !this.classID.equals(other.classID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Classes[ classID=" + classID + " ]";
    }
    
}
